package org.colcon.web.model.title;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.colcon.web.model.Group;
import org.colcon.web.model.Model;
import org.colcon.web.model.Title;
import org.colcon.web.model.framework.IPower;

public class RepresentativeTitle extends Title implements Serializable
{
	private static final long serialVersionUID = 3368263417307717987L;

	public RepresentativeTitle()
	{
		this(new HashMap<String, String>());
	}
	
	public RepresentativeTitle(Map<String, String> args)
	{
		this(args.get(GROUP));
	}
	
	public RepresentativeTitle(String group)
	{
		super(
				Model.getTitleContainer(group), 
				Group.REPRESENTATIVE,
				"the user who represents the group " + group + " in " + Model.GROUP_CONGRESS, 
				1,
				new String[0],
				new IPower[0]
		);
	}
	
	public boolean addHolder(String id)
	{
		boolean result = super.addHolder(id);
	
		Model.getGroupCongress().addMember(id);
		
		return result;
	}
	
	public boolean removeHolder(String id)
	{
		boolean result = super.removeHolder(id);
		
		Model.getGroupCongress().removeMember(id);
		
		return result;
	}
}
